package com.osce.face.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csce.domain.entity.face.FaceRecord;
import com.doudou.core.str.StrUtil;
import com.osce.common.utils.DateUtils;
import com.osce.face.mapper.FaceRecordMapper;
import com.osce.interfaces.face.IFaceRecordService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 人脸识别记录Service业务层处理
 *
 * @author zzx
 * @since 2023-11-21
 */
@Service
public class FaceRecordServiceImpl extends ServiceImpl<FaceRecordMapper, FaceRecord> implements IFaceRecordService {


    /**
     * 查询人脸识别记录
     *
     * @param id 人脸识别记录主键
     * @return 人脸识别记录
     */
    @Override
    public FaceRecord selectFaceRecordById(Long id) {
        return baseMapper.selectFaceRecordById(id);
    }

    /**
     * 查询人脸识别记录列表
     *
     * @param faceRecord 人脸识别记录
     * @return 人脸识别记录
     */
    @Override
    public List<FaceRecord> selectFaceRecordList(FaceRecord faceRecord) {
        return baseMapper.selectFaceRecordList(faceRecord);
    }

    /**
     * 新增人脸识别记录
     *
     * @param faceRecord 人脸识别记录
     * @return 结果
     */
    @Override
    public int insertFaceRecord(FaceRecord faceRecord) {
        faceRecord.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertFaceRecord(faceRecord);
    }

    @Override
    public int insertFaceRecord(Long userId, Long examId, String info, Object... params) {
        return insertFaceRecord(FaceRecord.builder().userId(userId).examId(examId).info(StrUtil.format(info, params)).build());
    }

    /**
     * 修改人脸识别记录
     *
     * @param faceRecord 人脸识别记录
     * @return 结果
     */
    @Override
    public int updateFaceRecord(FaceRecord faceRecord) {
        return baseMapper.updateFaceRecord(faceRecord);
    }

    /**
     * 批量删除人脸识别记录
     *
     * @param ids 需要删除的人脸识别记录主键
     * @return 结果
     */
    @Override
    public int deleteFaceRecordByIds(Long[] ids) {
        return baseMapper.deleteFaceRecordByIds(ids);
    }

    /**
     * 删除人脸识别记录信息
     *
     * @param id 人脸识别记录主键
     * @return 结果
     */
    @Override
    public int deleteFaceRecordById(Long id) {
        return baseMapper.deleteFaceRecordById(id);
    }
}
